package com.goodving.guli.server;

import android.content.Context;
import android.os.Build.VERSION;
import android.text.TextUtils;

import com.goodving.guli.activity.AppConfig;
import com.goodving.guli.activity.SettingContainerActivity;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.model.C1495q;
import com.goodving.guli.bt.model.DeviceInfo;
import com.goodving.guli.bt.model.Friend;
import com.goodving.guli.bt.model.LoginData;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.model.ShareData;
import com.goodving.guli.bt.model.ShareData.TimeType;
import com.goodving.guli.bt.model.SportBaseInfo;
import com.goodving.guli.bt.model.SystemInfo;
import com.goodving.guli.bt.profile.scale.C3515h;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.WeightHwInfo;
import com.goodving.guli.bt.weight.UserInfo;
import com.goodving.guli.model.BraceletBtInfo;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.model.LoginInfo;
import com.goodving.guli.model.ThirdLoginState;
import com.goodving.guli.server.sync.SyncServerData;
import com.goodving.guli.utility.Constants;
import com.goodving.guli.view.C3657a;
import com.goodving.guli.view.C4220a;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import cn.com.smartdevices.bracelet.config.C0886a;
import cn.com.smartdevices.bracelet.config.Config;
import cz.msebera.android.httpclient.Header;


public class WebAPI { // C1329l
    public static String f6820a;

    static {
        f6820a = "WebAPI";
    }

    public static DeviceInfo m11583a(Context context, int i) {
        if (context == null) {
            return null;
        }
        switch (i) {
            case 0 /*0*/:
                BraceletBtInfo readBraceletBtInfo = Keeper.readBraceletBtInfo();
                String d = C0886a.m9069d(context);
                if (!readBraceletBtInfo.m25394a() || TextUtils.isEmpty(d)) {
                    return null;
                }
                if (TextUtils.isEmpty(readBraceletBtInfo.f19639e)) {
                    return new DeviceInfo(i, d, readBraceletBtInfo.f19636b, readBraceletBtInfo.f19638d, readBraceletBtInfo.f19635a);
                }
                return new DeviceInfo(i, d, readBraceletBtInfo.f19636b, readBraceletBtInfo.f19638d, readBraceletBtInfo.f19639e, readBraceletBtInfo.f19635a);
            case 1 /*1*/:
                WeightHwInfo readWeightHwInfo = Keeper.readWeightHwInfo();
                return readWeightHwInfo.isValid() ? new DeviceInfo(i, readWeightHwInfo.deviceId, readWeightHwInfo.address, readWeightHwInfo.fwVersion) : null;
            case 2 /*2*/:
//                return new DeviceInfo(i, WeiboAuthException.DEFAULT_AUTH_ERROR_CODE, WeiboAuthException.DEFAULT_AUTH_ERROR_CODE, WeiboAuthException.DEFAULT_AUTH_ERROR_CODE);

            default:
                return null;
        }
    }

    public static void m11584a() {
    }

    public static void m11585a(Context context, LoginData loginData, AsyncHttpResponseHandler responseHandler) { // C0643h
        if (loginData.isValid()) {
            RequestParams requestParams = new RequestParams(); // RequestParams
            requestParams.put(SyncServerData.f8320f, C3657a.f18328f + loginData.uid); // m21070a
            requestParams.put(C4220a.f20892o, loginData.security);
            requestParams.put(SettingContainerActivity.f9257a, Config.m8872d());
//            requestParams.put("imei", C0668a.m8137b(context));
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.am), requestParams, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void uploadLogFileBlock(Context context, LoginData loginData, File file, AsyncHttpResponseHandler responseHandler) { // m11586a
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            try {
                a.put(ClientDataConstants.ar, file.getName());
                a.put(ClientDataConstants.aq, file); // m21063a
            } catch (FileNotFoundException e) {
            }
            WebAPI.m11587a(context, a);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6791j), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    private static void m11587a(Context context, RequestParams requestParams) {
        if (context != null && requestParams != null) {
            SystemInfo a = C1327j.m11574a(context);
            if (a != null) {
                requestParams.put(ClientDataConstants.ab, a.getMiuiVersionCode());
                requestParams.put(ClientDataConstants.ac, a.getMiuiVersionName());
                requestParams.put(ClientDataConstants.ad, a.getPhoneBrand());
                requestParams.put(ClientDataConstants.ae, a.getPhoneModel());
                requestParams.put(ClientDataConstants.af, a.getPhoneSystem());
                requestParams.put(ClientDataConstants.ak, a.getSoftVersion());
                if (DeviceSource.hasBindBracelet()) {
                    BraceletBtInfo readBraceletBtInfo = Keeper.readBraceletBtInfo();
                    if (readBraceletBtInfo != null) {
                        requestParams.put(ClientDataConstants.ag, readBraceletBtInfo.f19638d);
                    }
                }
//                if (DeviceSource.hasBindShoesDevice()) {
//                    String a2 = C1601b.m12698a(context, false);
//                    if (!TextUtils.isEmpty(a2)) {
//                        requestParams.put(ClientDataConstants.aj, C1593c.m12648a(context, a2));
//                    }
//                }
            }
        }
    }

    public static void m11588a(Context context, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6796x), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11589a(Context context, AsyncHttpResponseHandler responseHandler, String str) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put(ClientDataConstants.au, str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6769N), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11590a(Context context, String str, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put(ClientDataConstants.bb, str);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6771P), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void uploadUserWeightGoal(Context context, String str, String str2, int i, float f, float f2, int i2, long j, AsyncHttpResponseHandler responseHandler) { // m11591a
        LoginData f3 = C0886a.m9071f(context);
        if (f3.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f3);
            a.put(SyncServerData.f8320f, str);
            a.put("fuid", str2);
            a.put("goal_type", i); // m21061a
            a.put("currentval", Float.valueOf(f)); // m21069a
            a.put("goal", Float.valueOf(f2));
            a.put(ClientDataConstants.PARAM_BIND_HEIGHT, i2);
            a.put("date_time", j); // m21062a
            String a2 = URL.m10531a(ClientConstant.ah);
            GuliLog.tracePrintInfo(f6820a, "url for uploadUserWeightGoal " + AsyncHttpClient.getUrlWithQueryString(true, a2, a)); // m21102a
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        f3.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void uploadUserWeightGoal(Context context, String str, String str2, int i, long j, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put(SyncServerData.f8320f, str);
            a.put("fuid", str2);
            a.put("goal_type", i);
            a.put("date_time", j);
            String a2 = URL.m10531a(ClientConstant.al);
            GuliLog.tracePrintInfo(f6820a, "url for uploadUserWeightGoal " + AsyncHttpClient.getUrlWithQueryString(true, a2, a));
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void getUserWeightGoalList(Context context, String str, String str2, int i, String str3, int i2, AsyncHttpResponseHandler responseHandler) { // m11593a
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put(SyncServerData.f8320f, str);
            a.put("fuid", str2);
            a.put("goal_type", i);
            a.put("etime", str3);
            a.put("num", i2);
            String a2 = URL.m10531a(ClientConstant.ak);
            GuliLog.tracePrintInfo(f6820a, "url for getUserWeightGoalList is " + AsyncHttpClient.getUrlWithQueryString(true, a2, a));
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void getUserWeightGoalList(Context context, String str, String str2, int i, String str3, String str4, AsyncHttpResponseHandler responseHandler) { // m11594a
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put(SyncServerData.f8320f, str);
            a.put("goal_type", i);
            a.put("fuid", str2);
            a.put("stime", str3);
            a.put("etime", str4);
            String a2 = URL.m10531a(ClientConstant.aj);
            GuliLog.tracePrintInfo(f6820a, "url for getUserWeightGoalList is " + AsyncHttpClient.getUrlWithQueryString(true, a2, a));
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11595a(LoginData loginData, int i, int i2, int i3, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aw, i);
            a.put("data_type", i2);
            if (i3 == ShareData.TimeType.DAY.ordinal()) {
                a.put(ClientDataConstants.ax, "day");
            } else if (i3 == TimeType.WEEK.ordinal()) {
                a.put(ClientDataConstants.ax, "week");
            } else if (i3 == ShareData.TimeType.MONTH.ordinal()) {
                a.put(ClientDataConstants.ax, "month");
            }
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6757B), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11596a(LoginData loginData, int i, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aQ, i);
            String a2 = URL.m10531a(ClientConstant.f6758C);
            GuliLog.tracePrintInfo(f6820a, "checkBetaApk, url =" + a2);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void syncUserInfosToLocal(LoginData loginData, int i, boolean z, AsyncHttpResponseHandler responseHandler) { // m11597a
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            if (z) {
                a.put("fuid", "all");
            } else {
                a.put("fuid", i);
            }
            String a2 = URL.m10531a(ClientConstant.ad);
            GuliLog.tracePrintInfo(f6820a, "Sync UserInfos To Local : " + a2);
            GuliLog.tracePrintInfo(f6820a, " url tmp syncUserInfosToLocal " + AsyncHttpClient.getUrlWithQueryString(true, a2, a));
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11598a(LoginData loginData, long j, int i, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aG, i + C3657a.f18328f);
            a.put("offset", j + C3657a.f18328f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6777V), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11599a(LoginData loginData, long j, long j2, int i, boolean z, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("fuid", i);
            if (j > -1) {
                a.put(SportBaseInfo.KEY_START_TIME, j);
            }
            if (j2 > -1) {
                a.put(SportBaseInfo.KEY_END_TIME, j2);
            }
            if (z) {
                a.put("fuid", "all");
            } else {
                a.put("fuid", i);
            }
            a.put(ClientDataConstants.aa, 1);
            String a2 = URL.m10531a(ClientConstant.aa);
            GuliLog.tracePrintInfo(f6820a, "Sync WeightInfos To Local : " + a2);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11600a(LoginData loginData, long j, long j2, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aH, j + C3657a.f18328f);
            a.put(ClientDataConstants.f6751v, (j2 / 1000) + C3657a.f18328f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6779X), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11601a(LoginData loginData, long j, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(C4220a.f20891n, C3657a.f18328f + j);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6784c), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11602a(LoginData loginData, long j, String str, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aK, j + C3657a.f18328f);
            a.put("nick", str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6780Y), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

//    public static void m11603a(LoginData loginData, long j, boolean z, AsyncHttpResponseHandler responseHandler) {
//        if (loginData.isValid()) {
//            RequestParams a = ClientDataConstants.m11558a(loginData);
//            a.put(C1494j.f7520i, j + C3657a.f18328f);
//            a.put("status", z ? Constants.VIA_TO_TYPE_QQ_GROUP : Constants.VIA_RESULT_SUCCESS);
//            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6774S), a, responseHandler);
//            return;
//        }
//        loginData.getClass();
//        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
//    }

    public static void m11604a(LoginData loginData, PersonInfo personInfo, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.PARAM_BIND_BIRTHDAY, personInfo.birthday);
            a.put(ClientDataConstants.PARAM_BIND_GENDER, C3657a.f18328f + personInfo.gender);
            a.put(ClientDataConstants.PARAM_BIND_HEIGHT, C3657a.f18328f + personInfo.height);
            a.put(Friend.f7788d, C3657a.f18328f + (personInfo.weight * 1000.0f));
            a.put(ClientDataConstants.f6754y, personInfo.nickname);
            a.put(ClientDataConstants.PARAM_BIND_ICON_URL, personInfo.avatarUrl);
            a.put(ClientDataConstants.PARAM_BIND_PERSON_SIGNATURE, personInfo.personSignature);
            a.put(ClientDataConstants.PARAM_BIND_PERSON_SH, personInfo.sh);
            a.put(ClientDataConstants.am, personInfo.age + C3657a.f18328f);
//            a.put(C4030o.f20252x, personInfo.getVersion() + C3657a.f18328f);
//            String readCityCode = Keeper.readCityCode();
//            if (!TextUtils.isEmpty(readCityCode)) {
//                a.put(DistrictSearchQuery.KEYWORDS_CITY, readCityCode);
//            }
//            readCityCode = Keeper.readCountryCode();
//            if (!TextUtils.isEmpty(readCityCode)) {
//                a.put("country", readCityCode);
//            }
//            C2576k i = new C2584r().m19594i();
//            try {
//                a.put(LocationManagerProxy.KEY_LOCATION_CHANGED, Utils.m8051c(URLEncoder.encode(i.m19550b(personInfo.location), C4220a.bO)));
//                a.put(ClientDataConstants.PARAM_BIND_PERSON_ALARM_CLOCK, Utils.m8051c(URLEncoder.encode(i.m19550b(personInfo.alarmClockItems), C4220a.bO)));
//                a.put(C1493i.f7517e, Utils.m8051c(URLEncoder.encode(i.m19550b(personInfo.miliConfig), C4220a.bO)));
//                GuliLog.m12370d(f6820a, "pInfo.miliConfig = " + personInfo.miliConfig);
//                GuliLog.tracePrintInfo("SCORPIONEAL", "WebAPI updateProfile  gson.toJson(pInfo.miliConfig) " + i.m19550b(personInfo.miliConfig));
//            } catch (UnsupportedEncodingException e) {
//                e.printStackTrace();
//            }
//            readCityCode = URL.m10531a(ClientConstant.f6783b);
//            GuliLog.tracePrintInfo(f6820a, "updateProfile : " + AsyncHttpClient.getUrlWithQueryString(true, readCityCode, a));
//            if (personInfo.avatarPath == null || (personInfo.getNeedSyncServer() & 1) == 0) {
//                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, readCityCode, a, responseHandler);
//                return;
//            }
//            try {
//                a.put("icon", new File(personInfo.avatarPath));
//                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, readCityCode, a, responseHandler);
//                return;
//            } catch (FileNotFoundException e2) {
//                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, readCityCode, a, responseHandler);
//                return;
//            }
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

//    public static void m11605a(LoginData loginData, UserLocationData userLocationData, AsyncHttpResponseHandler responseHandler) {
//        if (loginData.isValid()) {
//            RequestParams a = ClientDataConstants.m11558a(loginData);
//            try {
//                a.put(LocationManagerProxy.KEY_LOCATION_CHANGED, C3657a.f18328f + URLEncoder.encode(userLocationData.toString(), C4220a.bO));
//            } catch (UnsupportedEncodingException e) {
//                e.printStackTrace();
//            }
//            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6786e), a, responseHandler);
//            return;
//        }
//        loginData.getClass();
//        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
//    }

    public static void syncUserInfoToServer(LoginData loginData, UserInfo userInfo, boolean z, AsyncHttpResponseHandler responseHandler) { // m11606a
        if (loginData.isValid()) {
            RequestParams requestParams = ClientDataConstants.m11558a(loginData);
            requestParams.put("fuid", userInfo.uid);
            requestParams.put(ClientDataConstants.PARAM_BIND_HEIGHT, userInfo.height);
            requestParams.put("nickname", userInfo.name);
            requestParams.put("brithday", userInfo.birthday);
            requestParams.put(ClientDataConstants.PARAM_BIND_GENDER, userInfo.gender);
            if (z) {
                requestParams.put("icon", new ByteArrayInputStream(userInfo.avatarSource));
            }
            requestParams.put(Friend.f7788d, Float.valueOf(userInfo.weight));
            requestParams.put("targetweight", Float.valueOf(userInfo.targetWeight));
            String Url = URL.m10531a(ClientConstant.ac);
            GuliLog.tracePrintInfo(f6820a, "url tmp " + AsyncHttpClient.getUrlWithQueryString(true, Url, requestParams));
            GuliLog.tracePrintInfo(f6820a, "Sync UserInfo To Server : " + Url);
            // TBD hack here
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, AppConfig.URL_CREATE_PERSON, requestParams, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11607a(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6763H), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11608a(LoginData loginData, String str, C1495q c1495q, int i, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("deviceid", str);
            a.put("data_type", C3657a.f18328f + c1495q.m12347b());
            a.put("source", C3657a.f18328f + c1495q.m12346a());
            a.put(ClientDataConstants.as, C3657a.f18328f + i);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6792k), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11609a(LoginData loginData, String str, C1495q c1495q, String str2, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.PARAM_UPLOAD_DATA, str2);
            a.put("deviceid", str);
            a.put("data_type", C3657a.f18328f + c1495q.m12347b());
            a.put("source", C3657a.f18328f + c1495q.m12346a());
            a.put("data_len", C3657a.f18328f + str2.length());
            a.put("uuid", Keeper.readUUID());
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6782a), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11610a(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            String a2 = URL.m10531a(ClientConstant.f6762G);
            a.put(ClientDataConstants.av, str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11611a(LoginData loginData, String str, String str2, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("message", str);
            a.put(ClientDataConstants.PARAM_EMAIL, str2);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6787f), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11612a(LoginData loginData, String str, String str2, String str3, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("deviceid", str);
            a.put(ClientDataConstants.ao, str2);
            a.put(ClientDataConstants.ap, str3);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6790i), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11613a(LoginData loginData, HashMap<String, String> hashMap, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            HashMap<String, String> a = ClientConstant.m11563a(loginData);
            a.putAll(hashMap);
            String a2 = URL.m10531a(ClientConstant.f6783b);
            String str = (String) hashMap.get(ClientDataConstants.PARAM_BIND_ICON_PATH);
            a.remove(ClientDataConstants.PARAM_BIND_ICON_PATH);
            RequestParams requestParams = new RequestParams();

            for (HashMap.Entry<String, String> entry : a.entrySet()) {
                requestParams.put(entry.getKey(), entry.getValue());
            }
            if (str == null || str.length() < 1) {
                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, requestParams, responseHandler);
                return;
            }
            try {
                requestParams.put("icon", new File(str));
                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, requestParams, responseHandler);
                return;
            } catch (FileNotFoundException e) {
                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, requestParams, responseHandler);
                return;
            }
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11614a(LoginInfo loginInfo, String str, AsyncHttpResponseHandler responseHandler) {
        RequestParams requestParams = new RequestParams();
        requestParams.put(C3515h.f17664I, C3657a.f18328f + loginInfo.access_token);
        requestParams.put(ClientDataConstants.PARAM_EXPIRESLN, loginInfo.expiresIn);
        requestParams.put(ClientDataConstants.PARAM_MAC_TOKEN, loginInfo.mac_key);
        requestParams.put(ClientDataConstants.PARAM_MIID, loginInfo.userid);
        requestParams.put(ClientDataConstants.PARAM_ALIAS_NICK, loginInfo.aliasNick);
        requestParams.put(ClientDataConstants.PARAM_MILIAO_NICK, loginInfo.miliaoNick);
        if (loginInfo.miliaoIcon_320 == null || loginInfo.miliaoIcon_320.length() <= 0) {
            requestParams.put(ClientDataConstants.PARAM_MILIAO_ICON, loginInfo.miliaoIcon);
        } else {
            requestParams.put(ClientDataConstants.PARAM_MILIAO_ICON, loginInfo.miliaoIcon_320);
        }
        requestParams.put(ClientDataConstants.PARAM_MILIAO_FRIENDS, loginInfo.friends);
        requestParams.put("deviceid", str);
        requestParams.put(ClientDataConstants.aa, Constants.VIA_RESULT_SUCCESS);
        requestParams.put(ClientDataConstants.aX, loginInfo.refresh_token);
        requestParams.put(SyncServerData.f8332r, "android_" + VERSION.SDK_INT);
        requestParams.put(SettingContainerActivity.f9257a, Config.m8872d());
        String a = URL.m10531a(ClientConstant.f6785d);
        GuliLog.tracePrintInfo(f6820a, "send login url= " + a + "?" + requestParams.toString());
        AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a, requestParams, responseHandler);
    }

    public static void m11615a(String str, int i, LoginData loginData, ThirdLoginState thirdLoginState, AsyncHttpResponseHandler responseHandler) {
        String a = URL.m10531a(ClientConstant.f6764I);
        if (loginData.isValid()) {
            RequestParams a2 = ClientDataConstants.m11559a(str, loginData, thirdLoginState);
            a2.put(ClientDataConstants.aW, i);
            GuliLog.tracePrintInfo(f6820a, "bindThirdPartyApp url:" + a + " params:" + a2);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a, a2, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void queryBindStateFromServer(String str, LoginData loginData, ThirdLoginState thirdLoginState, AsyncHttpResponseHandler responseHandler) { // m11616a
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.av, str);
            a.put(ClientDataConstants.aR, thirdLoginState.uid);
            String a2 = URL.m10531a(ClientConstant.f6765J);
            GuliLog.tracePrintInfo(f6820a, "queryBindStateFromServer url:" + a2 + " params:" + a);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void queryLoginStateFromServer(String str, LoginData loginData, AsyncHttpResponseHandler responseHandler) { // m11617a
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.av, str);
            String a2 = URL.m10531a(ClientConstant.f6767L);
            GuliLog.tracePrintInfo(f6820a, "queryLoginStateFromServer url:" + a2 + " params:" + a);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11618a(String str, AsyncHttpResponseHandler responseHandler) {
        AdvHttpClient.post(GuliHttpClient.asyncHttpClient, str, null, responseHandler);
    }

    public static boolean m11619a(LoginData loginData, File file, String str, String str2, String str3, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            Map<String, String> a = ClientConstant.m11563a(loginData);
            a.put(ClientDataConstants.aA, str);
            a.put(ClientDataConstants.aB, str2);
            a.put(ClientDataConstants.aD, str3);
            String a2 = URL.m10531a(ClientConstant.f6770O);
            RequestParams requestParams = new RequestParams();
            for (Map.Entry<String, String> entry : a.entrySet()) {
                requestParams.put((String) entry.getKey(), (String) entry.getValue());
            }
            try {
                requestParams.put(ClientDataConstants.aC, file);
                AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, requestParams, responseHandler);
                return true;
            } catch (FileNotFoundException e) {
                return false;
            }
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
        return false;
    }

    public static void m11620b(Context context, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6797y), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11621b(LoginData loginData, long j, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aK, j + C3657a.f18328f);
            String a2 = URL.m10531a(ClientConstant.f6773R);
            GuliLog.tracePrintInfo(f6820a, "url:" + a2 + " params:" + a);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11622b(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6760E), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11623b(LoginData loginData, String str, C1495q c1495q, String str2, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.PARAM_UPLOAD_DATA, str2);
            a.put("deviceid", str);
            a.put("data_type", C3657a.f18328f + c1495q.m12347b());
            a.put("source", C3657a.f18328f + c1495q.m12346a());
            a.put("data_len", C3657a.f18328f + str2.length());
            a.put("uuid", Keeper.readUUID());
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6782a), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11624b(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            String a2 = URL.m10531a(ClientConstant.f6761F);
            a.put(ClientDataConstants.av, str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11625b(String str, LoginData loginData, ThirdLoginState thirdLoginState, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11559a(str, loginData, thirdLoginState);
            String a2 = URL.m10531a(ClientConstant.f6766K);
            GuliLog.tracePrintInfo(f6820a, "uploadToken2Server url:" + a2 + " params:" + a);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11626b(String str, AsyncHttpResponseHandler responseHandler) {
        RequestParams requestParams = new RequestParams();
        requestParams.put("code", str);
        String str2 = Config.m8876h().f4213w.booleanValue() ? Config.m8874f() + "huami.health.verifycode.json" : Config.m8873e() + "huami.health.verifycode.json";
        if (!TextUtils.isEmpty(URL.f5588u)) {
            str2 = URL.f5588u + "huami.health.verifycode.json";
        }
        GuliLog.tracePrintInfo(f6820a, "get login code url : " + str2 + "?" + requestParams.toString());
        AdvHttpClient.post(GuliHttpClient.asyncHttpClient, str2, requestParams, responseHandler);
    }

    public static void m11627c(Context context, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6768M), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11628c(LoginData loginData, long j, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aK, j + C3657a.f18328f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6775T), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11629c(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6793l), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11630c(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("deviceid", str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6789h), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11631d(Context context, AsyncHttpResponseHandler responseHandler) {
        LoginData f = C0886a.m9071f(context);
        if (f.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(f);
            a.put("type", 2);
            a.put("count", 100);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, URL.m10531a(ClientConstant.f6772Q), a, responseHandler);
            return;
        }
        f.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11632d(LoginData loginData, long j, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aK, j + C3657a.f18328f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6776U), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11633d(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6794v), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11634d(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put("deviceid", str);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6759D), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11635e(Context context, AsyncHttpResponseHandler responseHandler) {
        RequestParams requestParams = new RequestParams();
        requestParams.put("country", Locale.getDefault().getCountry());
        requestParams.put("resolution", Utils.m8105z(context));
        requestParams.put(SyncServerData.f8332r, Config.m8872d());
        GuliLog.m12370d("getStartingUpInfo", "country = " + Locale.getDefault().getCountry());
        GuliLog.m12370d("getStartingUpInfo", "resolution = " + Utils.m8105z(context));
        GuliLog.m12370d("getStartingUpInfo", "device = " + Config.m8872d());
        AdvHttpClient.m11551a(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.an), requestParams, responseHandler);
    }

    public static void m11636e(LoginData loginData, long j, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.aL, j + C3657a.f18328f);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6778W), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11637e(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6795w), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void syncDeletedUserInfosToServer(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) { // m11638e
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.JSONDATA, str);
            String a2 = URL.m10531a(ClientConstant.ae);
            GuliLog.tracePrintInfo(f6820a, "Sync Deleted UserInfos To Server : " + AsyncHttpClient.getUrlWithQueryString(true, a2, a));
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11639f(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6798z), a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void syncDeletedWeightInfosToServer(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) { // m11640f
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.JSONDATA, str);
            a.put(ClientDataConstants.aa, 1);
            String a2 = URL.m10531a(ClientConstant.ab);
            GuliLog.tracePrintInfo(f6820a, "Sync Deleted WeightInfos To Server : " + a2);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void m11641g(LoginData loginData, AsyncHttpResponseHandler responseHandler) {
        if (loginData.isValid()) {
            RequestParams requestParams = ClientDataConstants.m11558a(loginData);
            AdvHttpClient.post(GuliHttpClient.asyncHttpClient, URL.m10531a(ClientConstant.f6756A), requestParams, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }

    public static void syncWeightInfosToServer(LoginData loginData, String str, AsyncHttpResponseHandler responseHandler) { // m11642g
        if (loginData.isValid()) {
            RequestParams a = ClientDataConstants.m11558a(loginData);
            a.put(ClientDataConstants.JSONDATA, str);
            a.put(ClientDataConstants.aa, 1);
            String a2 = URL.m10531a(ClientConstant.f6781Z);
            GuliLog.tracePrintInfo(f6820a, "Sync WeightInfos To Server : " + a2);
            AdvHttpClient.post(GuliHttpClient.syncHttpClient, a2, a, responseHandler);
            return;
        }
        loginData.getClass();
        responseHandler.onFailure(Integer.MIN_VALUE, new Header[0], new byte[0], new Throwable());
    }
}
